import request from '@/utils/request';

export function indexInit() {
  return request({
    url:  '/merchant_backend/statistics',
    method: 'GET'
  })
}

/**
 * 首页未读消息条数
 */
export function handleMessageInit() {
  return request({
    url:  '/merchant_backend/notices/unread',
    method: 'GET'
  })
}

/**
 * 修改密码 验证原密码
 * @param {String} data 
 */
export function editPassword(password) {
  const data = {
    password
  }
  return request({
    url:  '/merchant_backend/profile/validate_old_pwd',
    method: 'POST',
    data
  })
}
/**
 * 修改密码 更新原密码
 * @param {String} data 
 */
export function handleUpdatePassword(password) {
  const data = {
    password
  }
  return request({
    url:  '/merchant_backend/profile/modify_pwd',
    method: 'put',
    data
  })
}

/**
 * 获取验证手机号
 */
export function handleGetPhone() {
  return request({
    url:  '/merchant_backend/profile/get_phone',
    method: 'GET'
  })
}

/**
 * 修改手机号-发送验证码
 */
export function handleEditPhone() {
  return request({
    url:  '/merchant_backend/profile/send_sms',
    method: 'GET'
  })
}

/**
 * 修改手机号码 提交
 * @param {Object} date 修改手机号 参数
 */
export function handleEditPhoneUpdate(date) {
  return request({
    url:  '/merchant_backend/profile/modify_phone',
    method: 'PUT',
    params: { code: date.vidateCode, phone: date.phoneVal }
  })
}